package com.license.ultilsoperation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.license.common.util.Constants;
import com.license.logic.alimentation.Alimentation;
import com.license.logic.alimentation.Food;
import com.license.logic.alimentation.FoodCharacteristics;
import com.license.logic.geneticAlgorithm.common.UtilsOperation;

public class UtilsOperationTest {

	@Test
	public void classifyAlimentationTest(){
		Alimentation alimentation = new Alimentation();
		
		List<Food> breakFast = this.getFoodList();
		List<Food> snack = this.getFoodList();
		List<Food> lunch = this.getFoodList();
		List<Food> dinner = this.getFoodList();
		
		alimentation.setBreakFast(breakFast);
		alimentation.setDinner(dinner);
		alimentation.setLunch(lunch);
		alimentation.setSnack(snack);
		
		UtilsOperation utilsOperation = new UtilsOperation();
		String str = utilsOperation.classifyAlimentation(alimentation);
		
		System.out.println(str);
	}
	
	@Test
	public void classifyFoodListTest(){
		
		UtilsOperation utilsOperation = new UtilsOperation();
		utilsOperation.initialize();
		List<Food> foods = getFoodList();
		
		Map <String, Integer> alimentationMap = this.getAlimentationMap();
		utilsOperation.classifyFoodList(alimentationMap, foods);
		
		for (String str : alimentationMap.keySet()){
			System.out.println(str + " : " + alimentationMap.get(str));
		}
		
	}
	
	private Map <String, Integer> getAlimentationMap(){
		Map <String, Integer> alimentationMap = new HashMap<String, Integer>();
		alimentationMap.put(Constants.VEGETABLE, 0);
		alimentationMap.put(Constants.FRUIT, 0);
		alimentationMap.put(Constants.MILK, 0);
		alimentationMap.put(Constants.GRAMINEA, 0);
		alimentationMap.put(Constants.OTHER, 0);
		return alimentationMap;
	}
	
	private List<Food> getFoodList(){
		
		List<Food> foods = new ArrayList<Food>();
		
		Food food1 = this.createFood("Tomatoe", 100, 2);
		Food food2 = this.createFood("Milk", 150, 1);
		Food food3 = this.createFood("Peanuts", 150, 2);
		
		foods.add(food1);
		foods.add(food2);
		foods.add(food3);
		return foods;
	}
	
	private Food createFood(String name, int gramsPerPortion, int portions){
		Food food = new Food();
		food.setName(name);
		food.setPortions(portions);
		FoodCharacteristics foodCharacteristics = new FoodCharacteristics();
		foodCharacteristics.setGramsPerPortion(gramsPerPortion);
		food.setCharacteristics(foodCharacteristics);
		return food;
	}
}
